<?php 

class Base {

    public function __construct() {
    
    echo "父类构造器!", PHP_EOL;
    
    }
    
    //静态
    public static function getSelf() {

    return new self();
    
    }
    
    //静态
    public static function getInstance() {
    
    return new static();
    
    }
    
    public function selfFoo() {
    
    return self::foo();
    
    }
    
    public function staticFoo() {
    
    return static::foo();
    
    }
    
    public function thisFoo() {
    
    return $this->foo();
    
    }
    
    public function foo() {
    
    echo "父类的 Foo!", PHP_EOL;
    
    }
    
    }
    
    class Child extends Base {
    
    public function __construct() {
    
    echo "子类构造器!", PHP_EOL;
    
    }
    
    public function foo() {
    
    echo "子类的Foo!", PHP_EOL;
    
    }
    
    }
    
    $base = Child::getSelf();//输出第一句：父类构造器（构造函数）（静态）
    
    $child = Child::getInstance();//输出第二句：父类构造器（构造函数）（静态）
    
    $child->selfFoo();
    
    $child->staticFoo();
    
    $child->thisFoo();


?>